-----------------------------------------------------------------------------
--
-- Module      :  Data.TypeLevel.Bit
-- Copyright   :
-- License     :  AllRightsReserved
--
-- Maintainer  :  eduard.sergeev@gmail.com
-- Stability   :  Highly Experimental
-- Portability :
--
-- Type-level bit data
--
-----------------------------------------------------------------------------

{-# LANGUAGE NoImplicitPrelude, TypeFamilies, TypeOperators, UndecidableInstances,
ScopedTypeVariables, FlexibleInstances #-}


module Data.TypeLevel.Bit (

   B0,
   B1,

   (:==:),

   Compare,
   (:<=:),

) where

import Prelude (Show(show))

import Data.TypeLevel.Families
import Data.TypeLevel.Class
import Data.TypeLevel.Boolean


-- | Bit 0
data B0 
-- | Bit 1
data B1


-- * Type-level "Eq" implementation
type instance B0 :==: B0 = True
type instance B0 :==: B1 = False
type instance B1 :==: B0 = False
type instance B1 :==: B1 = True

-- * Type-level "Ord" implementation
type instance Compare B0 B0 = EQ
type instance Compare B0 B1 = LT
type instance Compare B1 B0 = GT
type instance Compare B1 B1 = EQ
type instance B0 :<=: B0 = True
type instance B0 :<=: B0 = True
type instance B0 :<=: B1 = True
type instance B1 :<=: B0 = False
type instance B1 :<=: B1 = True


-- | Some normal typeclasse instances
instance Numerable B0 where
    toNumber _ = 0

instance Numerable B1 where
    toNumber _ = 1


instance Show B0 where
    show _ = "0"

instance Show B1 where
    show _ = "1"